package assetservicelogic

import (
	"context"
	"github.com/zeromicro/go-zero/core/logx"
	"property_service/dao/query"
	"property_service/internal/svc"
	"property_service/property_service"
	"property_service/utils/result"
)

type AccountBindingDelLogic struct {
	ctx    context.Context
	svcCtx *svc.ServiceContext
	logx.Logger
}

func NewAccountBindingDelLogic(ctx context.Context, svcCtx *svc.ServiceContext) *AccountBindingDelLogic {
	return &AccountBindingDelLogic{
		ctx:    ctx,
		svcCtx: svcCtx,
		Logger: logx.WithContext(ctx),
	}
}

// 删除绑定
func (l *AccountBindingDelLogic) AccountBindingDel(in *property_service.AccountBinding) (*property_service.Response, error) {
	m := query.Use(l.svcCtx.Gorm).AccountBinding
	if _, err := m.WithContext(l.ctx).Where(m.ID.Eq(in.ID)).Delete(); err != nil {
		return result.Err(err).Ed()
	}
	return result.Suc().DelEd()
}
